﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Dart
{
    public partial class DartBoard : Form
    {
        private FormDart formDart;

        public DartBoard(FormDart form)
        {
            InitializeComponent();
            formDart = form;
        }

        private void FormDartsBoard_Load(object sender, EventArgs e)
        {
            refreshData();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        private void ctlDartboard1_SingleThrown(object sender, Dart.DartbordEventArgs e)
        {
            formDart.addScore(e.Score, e.Score.ToString());
            refreshData();
        }

        private void ctlDartboard1_DoubleThrown(object sender, Dart.DartbordEventArgs e)
        {
            formDart.addScore(e.Score, "2 x " + e.Score.ToString());
            refreshData();
        }

        private void ctlDartboard1_TripleThrown(object sender, Dart.DartbordEventArgs e)
        {
            formDart.addScore(e.Score, "3 x " + e.Score.ToString());
            refreshData();
        }

        private void ctlDartboard1_NoScoreThrown(object sender, Dart.DartbordEventArgs e)
        {
            formDart.addScore(e.Score, "0");
            refreshData();
        }

        private void refreshData()
        {
            if (!formDart.finish)
            {
                labelPlayerName.Text = formDart.lblPlayerArray[formDart.currentPlayer - 1].Text;
                labelPlayerScore.Text = formDart.lblPlayerScoreArray[formDart.currentPlayer - 1].Text;
            }
        }

        private void ctlDartboard1_Load(object sender, EventArgs e)
        {

        }
    }
}
